<script>
document.getElementById('demo').innerHTML = 'Hello JavaScript!';
</script>
<!--
Cuando el navegador encuentra una etiqueta `<script>` con una ruta `src`,
carga el archivo especificado y lo ejecuta.
De esta manera, el código tiene acceso al contenido de la página.
-->
<!-- Todas las definiciones dentro se vuelven globales y están disponibles para todos los demás scripts -->
<script src="/assets/script1.js"></script>
<script src="/assets/script2.js"></script>
Uncaught SyntaxError: Cannot use import statement outside a module
<script type="module" src="/assets/index.js"></script>
// index.js
import app from './app.js';
app();
// app.js
export default () => {
console.log('Hello from module!');
};
Uncaught TypeError: Failed to resolve module specifier "lodash".
Relative references must start with either "/", "./", or "../".
# Especificamos el directorio de origen src
# Y el directorio donde colocar el código compilado
babel src -o dist
# Especificamos el directorio de origen stylesheets
# Y el directorio donde colocar el CSS compilado
sass --update stylesheets dist/stylesheets
mkdir webpack-demo
cd webpack-demo
npm init -y
npm i -D webpack webpack-cli
npx webpack init --force
npx webpack init
? Which of the following JS solutions do you want to use? ES6
? Do you want to use webpack-dev-server? Yes
? Do you want to simplify the creation of HTML files for your bundle? Yes
? Do you want to add PWA support? No
? Which of the following CSS solutions do you want to use? none
? Do you like to install prettier to format generated configuration? No
? Pick a package manager: npm
[webpack-cli] ℹ INFO Initialising project...
conflict package.json
? Overwrite package.json? overwrite
force package.json
create src/index.js
create README.md
create index.html
create webpack.config.js
create .babelrc
# salida sobre la instalación de bibliotecas
[webpack-cli] ⚠ Generated configuration may not be properly formatted as prettier is not installed.
[webpack-cli] Project has been initialised with webpack!
npx webpack serve